package com.lykj.modules.shop.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.lykj.core.tool.node.INode;
import com.lykj.modules.shop.entity.StoreCategory;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * 商品分类表视图实体类
 *
 * @author cxl
 * @since 2022-01-13
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "StoreCategoryVO对象", description = "商品分类表")
public class StoreCategoryVO extends StoreCategory implements INode<StoreCategoryVO> {
	private static final long serialVersionUID = 1L;
	/**
	 * 主键ID
	 */
	@ApiModelProperty(value = "主键ID")
	@JsonSerialize(using = ToStringSerializer.class)
	private Long id;
	/**
	 * 子孙节点
	 */
	@ApiModelProperty(value = "子孙节点")
	@JsonInclude(JsonInclude.Include.NON_EMPTY)
	private List<StoreCategoryVO> children;

	/**
	 * 是否有子孙节点
	 */
	@ApiModelProperty(value = "是否有子孙节点")
	@JsonInclude(JsonInclude.Include.NON_EMPTY)
	private Boolean hasChildren;

	@Override
	public List<StoreCategoryVO> getChildren() {
		if (this.children == null) {
			this.children = new ArrayList<>();
		}
		return this.children;
	}
}
